//
//@File    :	14.3_use_stuc.cpp
//@Time    :	2022/01/19 21:08:33
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	using a compsite class
//

//compile with studentc.cpp

#include <iostream>
#include "14.4_studenti.h"
using std::cin;
using std::cout;
using std::endl;

void set(Student & sa,int n);
const int pupils=3;//学生数量
const int quizzes=5;//考试数量

int main()
{
    Student ada[pupils]={Student(quizzes),Student(quizzes),Student(quizzes)};
    int i;
    for ( i = 0; i < pupils; ++i)
    {
        set(ada[i],quizzes);
    }
    cout<<"\nStudent List:\n";
    for ( i = 0; i < pupils; ++i)
    {
        cout<<ada[i].Name()<<endl;
    }
    cout<<"\nResults:";
    for (i = 0;i < pupils;++i)
    {
        cout<<endl<<ada[i];
        cout<<"average: "<<ada[i].Average()<<endl;
    }
    cout<<"Done.\n";
    system("pause");
    return 0;
}

void set(Student & sa,int n)
{
    cout<<"Please enter the student'sname: ";
    getline(cin,sa);
    cout<<"Please enter "<<n<<" quiz scoress:\n";
    for (int i = 0; i < n; i++)
    {
        cin>>sa[i]; 
    }
    while (cin.get()!='\n')
    {
        continue;
    }
    
}